#include "Helper.h"

void print_arr(vector<int>& arr, int length)
{
	cout << " ";
	for (int i = 0; i < length; i++)
	{
		cout << arr[i];
		if (i != length - 1)
			cout << ", ";
	}
	cout << endl;
}

int random(int min = 0, int max = 100) {
	random_device seed;//硬件生成随机数种子
	ranlux48 engine(seed());//利用种子生成随机数引擎
	uniform_int_distribution<> distrib(min, max);//设置随机数范围，并为均匀分布
	return distrib(engine);//随机数
}

void random_arr(vector<int>& arr, int length, int min, int max) {
	for (int i = 0; i < length; i++)
	{
		arr.push_back(random(min, max));
	}
}

void set_font_color(WORD color)
{
	HANDLE handle;//创建句柄 
	handle = GetStdHandle(STD_OUTPUT_HANDLE);//取标准输入输出句柄 
	SetConsoleTextAttribute(handle, color);//字符与 color相同 
}

void swap_(int* a, int* b) {
	*a = *a ^ *b;
	*b = *a ^ *b;
	*a = *a ^ *b;
}

void swap(int& a, int& b)
{
	int temp = a;
	a = b;
	b = temp;
}

void copy_arr(int* source, int* destination, int length) {
	for (int i = 0; i < length; i++)
	{
		destination[i] = source[i];
	}
}
